import * as actionTypes from './reducer/constants'
import { getAllgoodsRequest } from '../api/index'

export const checkGoodsAction = (goodsId) => ({
    type:actionTypes.CHECK_GOODS,
    data:goodsId
})

// data { goodsId,staus:"add|minus" }
export const changeGoodsNumAction = (data) => ({
    type:actionTypes.CHANGE_GOODS_NUM,
    data:data
})

export const checkAllGoodsAction = (data) => ({
    type:actionTypes.CHECK_ALL_GOODS,
    data
})

export const setAllGoods = (data) => ({
    type:actionTypes.SET_ALL_GOODS,
    data
})
export const getAllGoods = () => {
    return (dispatch) => {
        getAllgoodsRequest()
            .then(data => {
                dispatch(setAllGoods(data))
            })
    }
}